const { findAllGoods, findOneGood } = require('../model/goods')

// 获取商品列表
const getAllGoods = (req, resp) => {
    findAllGoods().then(list => {
        resp.json({
            code: 200,
            body: {
                list
            }
        })
    }).catch(err => {
        resp.json({
            code: 400,
            body: {
                err
            }
        })
    })
}

const getOneGood = (req, resp) => {
    const { _id } = req.body
    console.log(req.body);
    findOneGood({ _id }).then(docs => {
        resp.json({
            code: 200,
            body: {
                list: docs
            }
        })
    }).catch(err => {
        resp.json({
            code: 400,
            body: {
                err
            }
        })
    })

}
module.exports = {
    getAllGoods,
    getOneGood
}